<?php
require_once("chatFr.php");

class test extends PHPUnit_Framework_TestCase
{
	public function setUp()
	{
		echo "I run before each test\n";
	}
	
	public function testRegister()
    {
        $this->assertFileExists('/home/mbaye/Documents/dev web/mess_sessionFr.txt');
    }
	
	public function testfilewrite()
    {
		$fic_mess='mess_sessionFr.txt';
		$handle = fopen($fic_mess,"w");
		$date = date("d-m-Y");
		$heure = date("H:i");
		$message='salut';
		$login='mbaye';
		fwrite ($handle,$date);
		fwrite ($handle," ");
		fwrite ($handle,$heure);
		fwrite ($handle," ");
		fwrite ($handle,$login);
		fwrite ($handle," a dit: ");
		fwrite ($handle,$message);
		fwrite ($handle,"\r\n");
		fclose($handle);
		//on reouvre pour voir s'il a bien ecrit ce qu'on veut
		$handle = fopen($fic_mess,"r");
		$contenu = fread ($handle, filesize ($fic_mess));
			fclose ($handle);
			$tableau = explode("\r\n", $contenu);
			 foreach($tableau as $ligne)
			{
				$this->assertEquals($ligne, 'ssdsds');
			}
	}
	
	
	public function TearDown()
	{
		echo "I run after each test\n";
	}

	
}
